<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>浏览器定位</title>
        <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
    </head>
    <body>
        <div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
    </body>
</html>
<script type="text/javascript">

    $(function(){
    
        if ( $.browser.msie && ($.browser.version <8)){
            return false;
        }else{
            var map = new BMap.Map("container");            // 创建Map实例
            var point = new BMap.Point(116.331398,39.897445);
            map.centerAndZoom(point,17);

            var geolocation = new BMap.Geolocation();
            geolocation.getCurrentPosition(function(r){
                if(this.getStatus() == BMAP_STATUS_SUCCESS){
                    var mk = new BMap.Marker(r.point);
                    map.addOverlay(mk);
                    map.panTo(r.point);
                    //alert('您的位置：'+r.point.lng+','+r.point.lat);
                }
                else {
                    alert('failed'+this.getStatus());
                }        
            })
  
        
        }

 
    })
</script>
